package tedu.rocketmq.controller;

import org.apache.rocketmq.spring.core.RocketMQTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.messaging.Message;
import org.springframework.messaging.support.MessageBuilder;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
import tedu.rocketmq.param.TeduUser;

@RestController
public class TeduUserController {

    @Autowired
    RocketMQTemplate rocketMQTemplate;

    @GetMapping("/user")
    public String sendUser(TeduUser teduUser){
        //明确消息
        Message<TeduUser> message = MessageBuilder.withPayload(teduUser).build();
        //发送消息
        rocketMQTemplate.syncSend("user-topic02",message);
        return "success send user";
    }

}
